import pytest
# 配置全局calendar, yield前初始化测试数据, yield后清除测试数据
from api_test.api.calendar.calendar_api import CalendarApi


@pytest.fixture(name="calendar", scope="module")
def init_calendar():
    print("setup_module!!!")
    calendar = CalendarApi()
    yield calendar
    # print(f"\nteardown_module {calendar.calendar_ids}")
    # print(f"\nteardown_module!!!")
    # if calendar.calendar_ids:
    #     for calendar_id in calendar.calendar_ids:
    #         res = calendar.delete(calendar_id)
    #         # print(res)
    #         if res.get('code') != 0:
    #             if res.get('code') != 191003:
    #                 print(f"\n{calendar_id} 删除失败 {res}")
    #                 return f"\n{calendar_id} 删除失败 {res}"
    print("\n数据后置OK! ")